package sctu.edu.java.year2016.team01.xuhanmei.day20160601.chapter10_3;

import sctu.edu.java.year2016.team08.yangying.day20160527.chapter7_1.S;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Created by Administrator on 2016/6/1.
 * 创建map集合，创建Emp对象，并将Emp对象添加到集合中（Emp中的id作为Map集合的键）
 * 并将id为005的对象从集合中移除
 */
public class MapTest {
    public static void main(String[] args) {
        Map map = new HashMap<>();
        Emp emp = new Emp("001", "赵");
        Emp emp1 = new Emp("002", "钱");
        Emp emp2 = new Emp("005", "孙");
        Emp emp3 = new Emp("006", "李");


        map.put(emp.getid(), emp.getname());

        map.put(emp1.getid(), emp1.getname());

        map.put(emp2.getid(), emp2.getname());

        map.put(emp3.getid(), emp3.getname());


        Set set = map.keySet();


        Iterator it = set.iterator();
        System.out.print("移除前的map，无序：\n");
        while (it.hasNext()) {
            String str = (String) it.next();
            String name = (String) map.get(str);
            System.out.println(str + "" + name + "  ");
        }


        map.remove("005");
        System.out.println("移除005后的map\n" + map);

    }
}
